package com.yaj.myfactorysupport.controller;


import com.yaj.myfactorysupport.dto.TmWorkerDto;
import com.yaj.myfactorysupport.service.TmWorkerService;
import com.yaj.myfactorysupport.util.ErrorCodeEnum;
import com.yaj.myfactorysupport.util.RespBean;
import com.yaj.myfactorysupport.vo.TmWorkerVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wei
 * @since 2021-04-20
 */
@Api(tags = "TmWorkerController")
@RestController
@RequestMapping("/myfactorysupport/tm-worker")
public class TmWorkerController {
    @Autowired
    private TmWorkerService tmWorkerService;

//    /**
//     * 登录接口
//     * @return
//     */
//    @PostMapping("login")
//    public RespBean login(@RequestBody TmWorkerDto tmWorkerDto){
//        String token = tmWorkerService.checkUserLogin(tmWorkerDto);
//        return token== null?RespBean.error(ErrorCodeEnum.员工ID不存在.getCode(),ErrorCodeEnum.员工ID不存在.getMsg()):RespBean.success(token);
//    }

    @ApiOperation(value = "取得用户信息")
    @GetMapping("getWorkerInfo")
    public RespBean getWorkerInfo(String workerId){
        TmWorkerDto tmWorkerDto = new TmWorkerDto();
        tmWorkerDto.setWorkerId(workerId);

        TmWorkerVo workerInfo = tmWorkerService.getWorkerInfo(tmWorkerDto.getWorkerId());
        return workerInfo== null?RespBean.error(ErrorCodeEnum.员工ID不存在.getCode(),ErrorCodeEnum.员工ID不存在.getMsg()):RespBean.success(workerInfo);
    }
}

